import request from '@/utils/request'

export function fetchCategoryList(data) {
  return request({
    url: '/cloud-system/getCategoryList',
    method: 'post',
    data
  })
}

export function fetchCategoryOne(data) {
  return request({
    url: '/cloud-system/getOneCategoryDetail',
    method: 'post',
    data
  })
}

export function createCategory(data) {
  return request({
    url: '/cloud-system/createOneCategory',
    method: 'post',
    data
  })
}

export function updateCategory(data) {
  return request({
    url: '/cloud-system/updateOneCategory',
    method: 'post',
    data
  })
}

export function deleteCategory(data) {
  return request({
    url: '/cloud-system/deleteOneCategory',
    method: 'post',
    data
  })
}

export function lockCategory(data) {
  return request({
    url: '/cloud-system/lockOneCategory',
    method: 'post',
    data
  })
}

export function unlockCategory(data) {
  return request({
    url: '/cloud-system/unlockOneCategory',
    method: 'post',
    data
  })
}

/**
 * 移动节点顺序
 * @param {*} moveCategoryID 被移动的节点ID
 * @param {*} categoryID 移动到目的前后的节点ID
 * @param {*} moveSide 移动位置 1 代码移动到categoryID 之前， 2代表移动到categoryID之后
 * @param {*} token token身份认证
 * @returns
 */
export function moveOneCategory(moveCategoryID, categoryID, moveSide, token) {
  return request.post('/cloud-system/moveOneCategory', {
    moveCategoryID,
    categoryID,
    moveSide,
    token
  })
}
